home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / callback.001 / callback~ / callback / lib / dbase / makeconfigfile.c < prev    next >
C/C++ Source or Header  |  1996-07-23  |  951b  |  40 lines

  1.  
  2. #include "dbase.p"
  3.  
  4. /*
  5.     Make a new config file, before killing an mgetty process
  6. */
  7. void make_configfile()
  8. {
  9.     FILE      
  10.         *inf,
  11.         *outf;
  12.     char
  13.         *line,
  14.         *mgp,
  15.     *buffer;
  16.     int
  17.         index;
  18.              
  19.     mgp = getmgettypath();
  20.  
  21.     outf = xfopen(mgp, "w");        /* open the final file */
  22.  
  23.     for (index = 0; (line = get_ttyline(index)); index++)
  24.     {
  25.     buffer = linename("active", line);  /* make the active-filename */
  26.     if (!access(buffer, R_OK))        /* file exists ? */
  27.         {
  28.             log(log_max, "Appending %s to %s", buffer, mgp);
  29.  
  30.             inf = xfopen(buffer, "r");      /* open to read */
  31.             cpfile(inf, outf);              /* concatenate */
  32.             fclose(inf);
  33.         }
  34.     free(buffer);                /* free memory */
  35.     }                                   
  36.  
  37.     fclose(outf);                           /* close the destination file */
  38.     log(log_on, "New '%s' written", mgp);
  39. }
  40.